//
//  ClassifyInquiryController.m
//  Runone
//
//  Created by runone02 on 16/9/6.
//  Copyright © 2016年 runone. All rights reserved.
//

#import "ClassifyInquiryController.h"

@interface ClassifyInquiryController ()<UITextFieldDelegate>

@property (nonatomic, strong) UILabel *label;

@end

@implementation ClassifyInquiryController

- (void)viewDidLoad {
    [super viewDidLoad];
//    [self.roadTypeBtn setTitle:@"全部" forState:UIControlStateNormal];
//    [self.transTypeBtn setTitle:@"所有类型" forState:UIControlStateNormal];
//    [self.drivingDirectionsBtn setTitle:@"双向" forState:UIControlStateNormal];
    
    [self configTextField];
}

- (void)configTextField {
    _roadTypeTF.delegate         = self;
    _transTypeTF.delegate        = self;
    _drivingDerectionTF.delegate = self;
    _beginPileNOTF.delegate      = self;
    _beginPileNOTF.keyboardType  = UIKeyboardTypeNumberPad;
    _endPileNOTF.delegate        = self;
    _endPileNOTF.keyboardType    = UIKeyboardTypeNumberPad;
    
    UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 10, 30)];
    label1.text     = @"K";
    _beginPileNOTF.leftView     = label1;
    _beginPileNOTF.leftViewMode = UITextFieldViewModeAlways;
    
    UILabel *label2           = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 10, 30)];
    label2.text               = @"K";
    _endPileNOTF.leftView     = label2;
    _endPileNOTF.leftViewMode = UITextFieldViewModeAlways;
    
    _roadTypeTF.text            = @"全部";
    _transTypeTF.enabled        = NO;
    _roadTypeTF.enabled         = NO;
    _drivingDerectionTF.enabled = NO;
    _transTypeTF.text           = @"所有类型";
    _drivingDerectionTF.text    = @"双向";
}

#pragma mark - UItextFieldDelegate --- 限制输入框的输入的字数
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
    if (string.length == 0) return YES;
    NSInteger existedLength = textField.text.length;
    NSInteger selectedLength = range.length;
    NSInteger replaceLength = string.length;
    if (existedLength - selectedLength + replaceLength > 3) {
        return NO;
    }
    return YES;
}
@end
